#include <iostream>
#include <string>
#include <cstdlib>

// 包含VC++2005模块
#include "auth/OAuth2Server-vc2005.cpp"
#include "git/GitManager-vc2005.cpp"

class DevOpsPlatform {
private:
    OAuth2Server oauth;
    GitManager git;

public:
    void ShowBanner() {
        std::cout << "=== DevOps Platform VC++2005 ===" << std::endl;
        std::cout << "Compiler: Visual C++ 2005" << std::endl;
        std::cout << "Platform: Windows 32-bit" << std::endl;
        std::cout << "CI/CD Engine: Active" << std::endl;
        std::cout << "Multi-Compiler: VC++2005 Native" << std::endl;
        std::cout << "================================" << std::endl;
    }

    void ShowStatus() {
        std::cout << "Build Status:" << std::endl;
        std::cout << "  VC++2005: Native Build" << std::endl;
        std::cout << "  Architecture: Win32" << std::endl;
        std::cout << "  Runtime: MT (Static)" << std::endl;
        std::cout << std::endl;
        
        oauth.ShowStatus();
        std::cout << std::endl;
        git.ShowStatus();
    }

    void BuildVC2005() {
        std::cout << "Building with VC++2005..." << std::endl;
        std::cout << "Compiler: cl.exe 14.00" << std::endl;
        std::cout << "Flags: /MT /O2 /DNDEBUG" << std::endl;
        std::cout << "Modules: OAuth2, Git, Main" << std::endl;
        std::cout << "Build completed successfully!" << std::endl;
    }

    void RunServices() {
        std::cout << "Starting DevOps Services..." << std::endl;
        std::cout << "1. OAuth2 Authentication Server" << std::endl;
        std::cout << "2. Git Repository Manager" << std::endl;
        std::cout << "3. CI/CD Pipeline Engine" << std::endl;
        std::cout << "4. Build System (VC++2005)" << std::endl;
        std::cout << "All services started successfully!" << std::endl;
    }

    void OAuthTest() {
        std::cout << "OAuth2 Test:" << std::endl;
        std::string token = oauth.GenerateToken("devops-platform");
        std::cout << "Generated Token: " << token << std::endl;
        std::cout << "Token Valid: " << (oauth.ValidateToken(token) ? "Yes" : "No") << std::endl;
    }

    void GitTest() {
        std::cout << "Git Manager Test:" << std::endl;
        git.ListBranches();
        git.CreateBranch("vc2005-feature");
    }

    void ShowHelp() {
        std::cout << "DevOps Platform VC++2005 Commands:" << std::endl;
        std::cout << "  status     - Show system status" << std::endl;
        std::cout << "  build      - Build with VC++2005" << std::endl;
        std::cout << "  run        - Run all services" << std::endl;
        std::cout << "  oauth      - Test OAuth2" << std::endl;
        std::cout << "  git        - Test Git manager" << std::endl;
        std::cout << "  help       - Show this help" << std::endl;
    }
};

int main(int argc, char* argv[]) {
    DevOpsPlatform platform;
    
    platform.ShowBanner();

    if (argc > 1) {
        std::string command = argv[1];
        
        if (command == "status") {
            platform.ShowStatus();
        }
        else if (command == "build") {
            platform.BuildVC2005();
        }
        else if (command == "run") {
            platform.RunServices();
        }
        else if (command == "oauth") {
            platform.OAuthTest();
        }
        else if (command == "git") {
            platform.GitTest();
        }
        else if (command == "help") {
            platform.ShowHelp();
        }
        else {
            platform.ShowHelp();
        }
    } else {
        platform.ShowHelp();
    }

    return 0;
}
